<template>
  <view class="videoItem app_container_videoItem" @click="handleClick">
    <view class="img" :style="{ backgroundImage: 'url(' + video.img + ')' }"
      ><text>{{ video.time }}</text></view
    >
    <view class="videoItemContent">
      <view class="videoItemTitle">{{ video.title }}</view>
      <view class="videoItemIntro">
        {{ video.intro ? video.intro : '--' }}
      </view>
      <view class="videoItemBottom">
        <view class="tsg" v-for="tsg in video.tagNames" :key="tsg">{{ tsg }}</view>
        <view class="videoTime">
          {{
            video.updateTime
              ? dayjs(new Date()).format('YYYY-MM-DD') === dayjs(video.updateTime).format('YYYY-MM-DD')
                ? dayjs(video.updateTime).from(dayjs())
                : video.updateTime
              : video.createTime
              ? dayjs(new Date()).format('YYYY-MM-DD') === dayjs(video.createTime).format('YYYY-MM-DD')
                ? dayjs(video.createTime).from(dayjs())
                : video.createTime
              : ''
          }}
        </view>
      </view>
    </view>
  </view>
</template>
<script>
import dayjs from 'dayjs'
export default {
  props: {
    video: {
      type: Object
    }
  },
  data() {
    return {
      dayjs: null
    }
  },
  methods: {
    handleClick() {
      this.$emit('VIDEOLIST_CARD_CLICK', this.video)
    },
    fmtDate(val) {
      return dayjs(val).from(dayjs())
    }
  },
  created() {
    this.dayjs = dayjs
  }
}
</script>
<style lang="scss">
app-video-list-card {
  display: block;
}
.videoItem {
  width: 100%;
  min-height: 400rpx;
  border-radius: 20rpx;
  box-shadow: 0px 10rpx 40rpx 0px rgba(0, 0, 0, 0.1);
  .img {
    width: 690rpx;
    height: 200rpx;
    background-size: cover;
    background-repeat: no-repeat;
    position: relative;

    text {
      // min-width: 70rpx;
      height: 30rpx;
      line-height: 30rpx;
      text-align: center;
      background: rgba(0, 0, 0, 0.4);
      border-radius: 15rpx;
      color: #ffffff;
      position: absolute;
      padding: 0 13rpx;
      bottom: 20rpx;
      right: 23rpx;
    }
  }
  .videoItemContent {
    padding: 0 27rpx 0 23rpx;
    .videoItemTitle {
      line-height: 40rpx;
      font-size: 30rpx;
      @include text-ellipsis;
      padding: 13rpx 0 6rpx 0;
    }
    .videoItemIntro {
      height: 72rpx;
      line-height: 36rpx;
      font-size: 24rpx;
      color: #999999;
      @include ellipsis4line($lineCount: 2);
    }

    .videoItemBottom {
      padding-top: 18rpx;
      display: flex;
      flex-wrap: wrap;
      color: #999999;
      .tsg {
        min-width: 100rpx;
        height: 40rpx;
        font-size: 24rpx;
        padding: 0 27rpx;
        background: #fcfcfc;
        border: 2rpx solid #999999;
        border-radius: 20rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        &:nth-child(1) {
          margin-right: 21rpx;
        }
      }
      .tsg ~ .tsg {
        margin-right: 21rpx;
        margin-bottom: 16rpx;
      }
      .videoTime {
        margin-left: auto;
        margin-bottom: 16rpx;
      }
    }
  }
}
</style>
